<?php

namespace Admin\Controller;
use Think\Controller;
/**
 * Description of PollmentController
 * 评价问卷管理
 * @author motsqueen
 */
class PollmentController extends Controller{
    
    public function _initialize(){
        header("Content-Type: text/html; charset=UTF-8");
    }
    
    public function index(){
        // 显示首页面，提供帮助说明。
        $this->display();
    }
    
    public function fdypoll(){
        // 显示问卷列表
        $poll_db = M('pollment');
        // $now = time();
        $now = 14400000;
        $data['type'] = 1;
        $data['begin'] = array('elt',$now);
        $data['end'] = array('egt',$now);
        $data['visible'] = 1;
        $ret = $poll_db->where($data)->order('time_at desc')->select();
        echo "<pre>";
        print_r($ret);
    }
    
    public function bzrpoll(){
        // 显示问卷列表
        $poll_db = M('pollment');
        // $now = time();
        $now = 14400000;
        $data['type'] = 2; // 班主任是2
        $data['begin'] = array('elt',$now);
        $data['end'] = array('egt',$now);
        $data['visible'] = 1;
        $ret = $poll_db->where($data)->order('time_at desc')->select();
        echo "<pre>";
        print_r($ret);
    }
    
    public function toggle_visible(){
        // 使得过期或完成的问卷不可见。
        $id = I('get','0','int');
        $pdb = M('pollment');
        $condition['id'] = $id;        
        $row = $pdb->where($condition)->find();
        if ($row['visible'] == 0){
            $data['visible'] = 1;
        } else {
            $data['visible'] = 0;
        }
        $pdb->where($condition)->save($data);        
    }
        
    public function new_poll(){
        // 显示新建表单
        $this->display();
    }
        
    public function handler(){
        // 校验并处理表单
        $pdb = M('pollment');
    }
    
    public function edit_poll(){
        $id = I('get','0','int');
    }
    
    
}
